<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

</body>
</html>
<script>
    //得到总页码
    $.ajax({
        url : ThinkPHP['MODULE'] + '/Topic/ajaxCount',
        type : 'POST',
        data : {

        },
        success: function(data, response, status){
            window.count = parseInt(data);
        }
    });
    //滚动条拖动
    window.scrollFlag = true;
    window.first = 10;
    window.page = 1;
    $(window).scroll(function () {
        if (window.page < window.count) {
            if (window.scrollFlag) {
                if ($(document).scrollTop() >= ($('#loadmore').offset().top + $('#loadmore').outerHeight() - $(window).height() - 20)) {
                    setTimeout(function(){
                        $.ajax({
                            url: ThinkPHP['MODULE'] + '/Topic/ajaxlist',
                            type: 'POST',
                            data: {
                                first: window.first,
                            },
                            success: function(data, response, status){
                                $('#loadmore').before(data);
                                allHeight();
                            }
                        });
                        window.scrollFlag = true;
                        window.first += 10;
                        window.page += 1;
                    }, 500);
                    window.scrollFlag = false;
                }
            }
        } else {
            $('#loadmore').html('没有更多数据');
        }
    });
</script>